package company.xiaomi;

import java.util.Scanner;

public class Mi1A {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String s = in.next();
            char[] ch = s.toCharArray();
            int length = ch.length;
            if (length < 8 || length > 120) {
                System.out.println(1);
                continue;
            }
            int num = 0;
            int bigwrite = 0;
            int smallwrite = 0;
            int zifu = 0;
            for (int i = 0; i < ch.length; i++) {
                if (ch[i] >= '0' || ch[i] <= '9') {
                    num++;
                }
                if (ch[i] >= 'a' || ch[i] <= 'z') {
                    smallwrite++;
                }
                if (ch[i] >= 'A' || ch[i] <= 'Z') {
                    bigwrite++;
                }
                if (ch[i] == '!' && ch[i] == '#' && ch[i] == '$') {
                    zifu++;
                }
            }
            if (num > 0 && bigwrite > 0 && smallwrite > 0 && zifu > 0) {
                System.out.println(0);
            } else {
                System.out.println(2);
            }
        }
    }
}
